
    document.getElementById("welcome").onclick=function(e){
        var welcome = document.getElementById("welcome");
        var fome1 = document.getElementById("login");
        var fome2 = document.getElementById("registe");
        var flag = document.getElementById("loginForm").flag;
//        console.log(flag);
        
        if(flag.value == 0){
            fome1.style.left = "45%";
           
            welcome.style.top = "10%";
            welcome.style.transform="rotate(355deg) scale(0.75)";
            
            flag.value = 1;
        }else{
            fome1.style.left = "150%";
            fome2.style.left = "-50%";
            welcome.style.top = "40%";
            welcome.style.transform="rotate(-355deg) scale(1.5)";
            flag.value = 0; 
        }
    }
    
    function goRegiste(){
        var fome1 = document.getElementById("login");
        var fome2 = document.getElementById("registe");
      
        fome2.style.left = "45%";
        fome1.style.left = "-50%";
    }

 function goLogin(){
        var fome1 = document.getElementById("login");
        var fome2 = document.getElementById("registe");
      
        fome2.style.left = "150%";
        fome1.style.left = "45%";
    }
 
 
 function tryLogin1(){
 	document.getElementById("checkFlag").style.color='red';
 	document.getElementById("checkFlag").innerHTML="账户名密码不匹配！";
 }
 function createXMLHttpRequest() {       //万能模板

	    var XMLHttpReq;

	    if (window.XMLHttpRequest) {   // 是Mozilla浏览器

	        XMLHttpReq = new XMLHttpRequest();
	    } else if (window.ActiveXObject()) { // IE浏览器
	        try {
	            XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP"); //因为ie也会出现不兼容所以抛异常
	        } catch (e) {
	            XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");  //微软的，记住就好
	        }
	}
	    return XMLHttpReq;
	}
function tryLogin(){
	
	var account=document.getElementById('loginForm').account.value;
	var password = document.getElementById('loginForm').password.value;
	
	{
		var post_data = {
		  "account":account,
		  "password":password
		};
		$.ajax({
		  url: '/login/',
		  type: "POST",
		  data: post_data,
		  success: function (data) {
			data = JSON.parse(data);
			if (data["status"] == 1) {
				// alert(data["result"]);
				window.location.href='/space/?account='+account;
			} else {
			  	alert("FAULT!");
			}
		  }
		});
	  } 
	}
function tryRegiste(){
	
	 var xmlReq=createXMLHttpRequest(); 
	 
	 var name=document.getElementById('registeForm').name.value;
	 var account = document.getElementById('registeForm').account.value;
	 var password=document.getElementById('registeForm').password.value;
	 var firmPassword = document.getElementById('registeForm').firmPassword.value;
	 
	 if(!name){
	 	document.getElementById("checkFlag2").innerHTML="为自己起一个昵称吧！";
	 	return;
	 }
	 else if(!account){
	 	document.getElementById("checkFlag2").innerHTML="没有账号该怎样登陆呢！";
	 	return;
	 }
	 else if(!password){
	 	document.getElementById("checkFlag2").innerHTML="密码不能为空！";
	 	return;
	 }
	 else if(!firmPassword){
	 	document.getElementById("checkFlag2").innerHTML="确认密码不能为空！";
	 	return;
	 }
	 else if(password != firmPassword){
	 	document.getElementById("checkFlag2").innerHTML="确认密码与原密码不一致！请重新输入";
	 	document.getElementById('registeForm').password.value = null;
	 	document.getElementById('registeForm').firmPassword.value = null;
	 	return;
	 };
	 
	//  xmlReq.open("POST","/register/",true);
	//  xmlReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	//  xmlReq.send("account="+account+"&password="+password+"&name="+name+"&firmPassword="+firmPassword);
//	 console.log(xmlReq); 
	 
// 	 xmlReq.onreadystatechange=function(){
// 	             if(xmlReq.readyState==4){//判断对象状态是否完成
// 	               if(xmlReq.status==200){     //信息已经成功返回
// 	                var xmltext =xmlReq.responseText;  //得到AjaxServlet往外输出的数据
// 	                if(xmltext==1){   
//  						alert("恭喜您注册成功!");
//  						document.getElementById('registeForm').name.value="";
//  						 document.getElementById('registeForm').account.value="";
//  						 document.getElementById('registeForm').password.value="";
//  						 document.getElementById('registeForm').firmPassword.value="";
// // 						account=password=firmPassword = "";
 						
//                 	  	goLogin();
//                 	  	document.getElementById("checkFlag").innerHTML="";
//                 	  	document.getElementById("checkFlag2").innerHTML="";
//                   } else if (xmltext==0){
//                   		document.getElementById("checkFlag2").innerHTML="该账户已存在！";
                	  
//                   }
	                
// 	             }
// 	         }
// 	      }
{
	var post_data = {
	  "account":account,
	  "password":password,
	  "name":name
	};
	$.ajax({
	  url: '/register/',
	  type: "POST",
	  data: post_data,
	  success: function (data) {
		data = JSON.parse(data);
		if (data["status"] == 1) {
			alert(data["result"]);
			if(data['result']=="注册成功!"){
				window.location.href='/space/?account='+account;
			}
		} else {
			  alert("FAULT!");
		}
	  }
	});
  } 
	}
          
          
        //就绪状态处理器  
//      xhr.onreadystatechange = function() {  
//          if(this.readyState == 4) {          //忽略除DONE状态之外的所有状态  
//              if (this.status >= 200 && this.status <300) {  
//                  //成功  
//                  var data = xhr.responseText;  
//                  console.log(data);  
//                  if(data=="fail"){   
// 						document.getElementById("checkFlag").innerHTML="账户名密码不匹配！";
//                  }else {  
////                      var url = "Login"; 
////                      location.href=url;//get发送  
////                      post(url, {userId:data});   
//                  }  
//              }  
//              else {  
// 					document.getElementById("checkFlag").innerHTML="服务器端错误，请尝试重新登录";
//              }  
//          }  
//      }; 
//      
//      var account=document.getElementById("loginForm").account.value;
//      var account=document.getElementById("password").account.value;
//      xhr.open("GET", "Login?account=" + account.value + "&password=" + password.value,true);  
//      xhr.send(null);  
